package com.myapp.api.mapper;

import com.myapp.api.entity.StudentCourse;
import org.apache.ibatis.jdbc.SQL;

public class StudentCourseSqlProvider {

    public String insertSelective(StudentCourse record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("student_course");
        
        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=INTEGER}");
        }
        
        if (record.getSid() != null) {
            sql.VALUES("Sid", "#{sid,jdbcType=VARCHAR}");
        }
        
        if (record.getCid() != null) {
            sql.VALUES("Cid", "#{cid,jdbcType=VARCHAR}");
        }
        
        if (record.getScore() != null) {
            sql.VALUES("Score", "#{score,jdbcType=DOUBLE}");
        }
        
        if (record.getSecondscore() != null) {
            sql.VALUES("SecondScore", "#{secondscore,jdbcType=DOUBLE}");
        }
        
        if (record.getCreatetime() != null) {
            sql.VALUES("CreateTime", "#{createtime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdatetime() != null) {
            sql.VALUES("UpdateTime", "#{updatetime,jdbcType=TIMESTAMP}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(StudentCourse record) {
        SQL sql = new SQL();
        sql.UPDATE("student_course");
        
        if (record.getScore() != null) {
            sql.SET("Score = #{score,jdbcType=DOUBLE}");
        }
        
        if (record.getSecondscore() != null) {
            sql.SET("SecondScore = #{secondscore,jdbcType=DOUBLE}");
        }
        
        if (record.getCreatetime() != null) {
            sql.SET("CreateTime = #{createtime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdatetime() != null) {
            sql.SET("UpdateTime = #{updatetime,jdbcType=TIMESTAMP}");
        }
        
        sql.WHERE("id = #{id,jdbcType=INTEGER}");
        sql.WHERE("Sid = #{sid,jdbcType=VARCHAR}");
        sql.WHERE("Cid = #{cid,jdbcType=VARCHAR}");
        
        return sql.toString();
    }
}